home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / COMMUNIC / 1321.ZIP / MDMLITE.ARC / MDMLIGHT.ASM < prev    next >
Assembly Source File  |  1985-11-18  |  7KB  |  281 lines

  1. ;«RM132»
  2. ;
  3. ;The following program will display in the upper right hand side of display
  4. ;the active (SPACE, CONTROL ON, POSITIVE VOLTAGE) RS232 signals. The DTE
  5. ;generated signals are displayed in red, the DCE in green, also uart errors
  6. ;are shown in white. ***** NOTE if you have a mono display change DISPLAY_ADDR
  7. ;to b005 and the attributes in the "RSDATA" section to your preference. ****
  8. ;
  9. ;                      DISPLAY DEFINTIONS
  10. ;TMO    TIME OUT ERROR
  11. ;FRM    FRAMING ERROR
  12. ;PAR    PARITY ERROR
  13. ;OVR    OVERRUN ERROR
  14. ;CAR    Recieve Line Signal Detected --CARRIER DETECTED
  15. ;RNG    RING INDICATOR
  16. ;DSR    DATASET READY
  17. ;CTS    CLEAR TO SEND
  18. ;DTR    DATA TERMINAL READY
  19. ;RTS    REQUEST TO SEND
  20. ;
  21. ;This program installs itself in memory and the display can be toggled off and
  22. ;on by depressing the ALT AND LEFT HAND SHIFT KEYS simultaeneously.
  23. ;
  24. ;The display is turned on initialy (if you dont see anything put your modem
  25. ;into analog or local loopback). Since this routine is active only about 18 
  26. ;times per second it will not catch all error conditions that may occur
  27. ;during a normal communications session.
  28. ;
  29. ;
  30. ;
  31. ;   **********************************************************************
  32. ;If the display is active while accessing a floppy drive(works ok on hard disk)
  33. ;it sometimes causes data errors. If so toggle the display off while accessing
  34. ;the floppy. I suspect a routine such as this screws up the dos software timing?
  35. ;If anyone has any info about this I would appreciate hearing from you.
  36. ;
  37. ;
  38. ;I would like to hear your comments and suggesstions
  39. ;
  40. ;                               Tim Burmeister
  41. ;                           (COMPUSERVE 74736,2402)
  42. ;
  43. ;
  44. ;PS  Be gentle this is my first attemp at a useful assembly language program
  45. ;
  46. ;
  47. title   BREAKOUT BOX
  48. page    65,132
  49. ;
  50. ;        EQUATES
  51. ;
  52. DISPLAY_ADDR    equ 0b805H    ;second half of the top line
  53. ;
  54. ;        MACROS
  55. ;
  56. ERASE   MACRO            ;moves spaces to the display area
  57. .xlist
  58.     cld
  59.     mov ax,DISPLAY_ADDR
  60.     mov es,ax
  61.     mov cx,28H
  62.     mov ax,0020H
  63.         mov di,0
  64. rep     stosw
  65. .list
  66.         endm
  67. ;
  68. SHOW_232 MACRO    LINE
  69. .xlist
  70.     cli
  71.     push cs
  72.     pop ds
  73.     sti
  74.     mov ax,DISPLAY_ADDR
  75.     mov es,ax            ;set the destination segment up
  76.     mov cx,DATAEND - DATASTART    ;set the count (BYTE VALUE)
  77.     shr cx,1        ;divide count by 2 to equal number of words to move
  78.     cld            ;direction flag clear so stos will increment di
  79.     mov si,offset DATASTART    ;point to begining of the data
  80.     mov di,LINE*160        ;point dest to video memory
  81.         rep movsw
  82. .list
  83.     endm
  84. ;
  85. MOVE    MACRO
  86. LOCAL BLANK,THATSIT
  87. .xlist
  88.     jnc blank        ;if bit not set 
  89.     rep movsw
  90.     jmp THATSIT
  91. blank:    push si            ;save source index
  92.     mov si,offset spaces    ;new source index
  93.     rep movsw
  94.     pop si            ;restore si and add 8
  95.     add si,8
  96. thatsit: mov cx,4        ;restore cx:
  97. .list
  98.     endm
  99. ;
  100. GET_STATUS MACRO  PORT
  101. .xlist
  102.     cli
  103.     push ds
  104.     pop es            ;set es to point within dataseg(needed for the move macro)
  105.     sti
  106.     mov dx,03fdH        ;the first com port to look at
  107.     in al,dx
  108.     inc dx
  109.     mov ah,al
  110.     in al,dx
  111.     mov si,offset rsdata    ;point to the begining of ascii data
  112.     mov di,offset datastart    ;point to where we want to build message
  113.     mov cx,4        ;all messages are 4 words
  114.     shl ax,1
  115.     move            ;timeout
  116.     shl ax,1            ;ignore shift register
  117.     shl ax,1            ;ignore buffer register
  118.     shl ax,1            ;ignore break
  119.     shl ax,1
  120.     move            ;framing error
  121.     shl ax,1
  122.     move            ;parity error
  123.     shl ax,1
  124.     move            ;overrun error
  125.     shl ax,1            ;ignore data ready
  126.     shl ax,1
  127.     move            ;carrier detect
  128.     shl ax,1
  129.     move            ;ring detected
  130.     shl ax,1
  131.     move            ;dataset ready
  132.     shl ax,1
  133.     move            ;clear to send
  134.     mov dx,03fcH        ;now get rts and dtr
  135.     in al,dx        ;get the bits
  136.     shr al,1        ;dtr to carry flag
  137.     move
  138.     shr al,1        ;rts to carry flag
  139.     move
  140. .list
  141.     endm
  142. ;
  143. NEED    segment at 0
  144. zero    proc far
  145. zero    endp
  146. NEED    ends
  147. ;
  148. cseg    segment
  149.     org    100H
  150.     assume    cs:cseg
  151.     assume    ds:cseg
  152. BEGIN    proc    near
  153.     jmp INIT
  154. ;
  155. ;            DATA AREA
  156. ;
  157. DATASTART    equ $
  158. DATA    dw    40 dup(0020H)
  159. DATAEND equ $
  160. ;
  161. RSDATA        equ $
  162. TMO    DB    ' ',7,'T',7,'M',7,'O',7
  163. FRM    DB    ' ',7,'F',7,'R',7,'M',7
  164. PAR    DB    ' ',7,'P',7,'A',7,'R',7
  165. OVR    DB    ' ',7,'O',7,'V',7,'R',7
  166. CAR    DB    ' ',2,' ',2,'C',2,'D',2
  167. RNG    DB    ' ',2,' ',2,'R',2,'I',2
  168. DSR    DB    ' ',2,'D',2,'S',2,'R',2
  169. CTS    DB    ' ',2,'C',2,'T',2,'S',2
  170. DTR    DB    ' ',4,'D',4,'T',4,'R',4
  171. RTS    DB    ' ',4,'R',4,'T',4,'S',4
  172. RSDATAEND    EQU $
  173. ;
  174. SPACES    DW    4 DUP(0020H)
  175. ;
  176. DISPLAY_FLAG  DB 1
  177. KEYS_RELEASED DB 1        ;will be 1 if keys (ALT AND LEFT SHIFT) are released
  178. ;
  179.                 ;this is the entry point from the interupt
  180. ITRENT    equ $
  181.         push ax        ;save the registers
  182.         push bx
  183.         push cx
  184.         push dx
  185.         push ds
  186.         push es
  187.         push si
  188.         push di
  189.     push bp
  190.     mov ax,cs
  191.     mov ds,ax    ;set up my dataseg
  192.         sti        ;enable interupts
  193. ;
  194.             ;THE MAIN PROGRAM
  195. ;
  196.     xor ax,ax        ;set es so we can get the keyboard flags
  197.     mov es,ax
  198.     mov ax,es:[417H]    ;KB_FLAG
  199.     and al,10        ;get rid of the other bits
  200.     sub al,10        ;if zero flag set the l shift and alt keys are pressed
  201.     jnz NOTPR
  202.     cmp KEYS_RELEASED,1    ;if transition just took place then toggle display
  203.     jnz CONT
  204.     xor DISPLAY_FLAG,1    ;toggle display_flag
  205.     and KEYS_RELEASED,0    ;reset so the display will not toggle until next release and press
  206.     JMP CONT
  207. NOTPR:    or KEYS_RELEASED,1
  208. CONT:    cmp DISPLAY_FLAG,1
  209.     jz doit
  210.     cmp KEYS_RELEASED,0    ;if no display and keys were just released then erase
  211.     jnz bye
  212.     erase
  213. bye:    jmp exit
  214. ;
  215. doit:    GET_STATUS
  216.     INSTCHCK equ $
  217.     mov ax,DISPLAY_ADDR
  218.     mov es,ax        ;set es up to point to video memory
  219.      SHOW_232 0        ;display on line 0
  220. ;
  221. exit:    cli
  222.     pop bp            ;restore the registers
  223.     pop di
  224.     pop si
  225.     pop es
  226.     pop ds
  227.     pop dx
  228.     pop cx
  229.     pop bx
  230.     pop ax
  231.     sti
  232. jmpout: jmp    zero        ;will be filled
  233.                 ;in with the address of the timer int routine
  234. INIT:                ;initial entry point to set up vectors, this code
  235.         push    ds        ;will be discarded upon installing itself in memory
  236.         sub     ax,ax        ;zero ax
  237.         mov     ds,ax                   ;address interrupt vectors
  238.         mov     si,ds:[70H]             ;get the present interrupt values
  239.         mov     cx,ds:[72H]        ;usually points to an iret
  240.         mov     ds,cx                   ;entry to present interupt handler
  241. ;                     Next lines determine if this program is
  242. ;                     already installed
  243.         mov bx,cs:INSTCHCK
  244.      cmp word ptr [si+INSTCHCK-ITRENT],bx
  245.     jne instal
  246.     pop ds
  247.     call beep            ;complain LOUDLY if this program alredy in memory
  248.     int 20H                ;exit
  249. instal: pop ds
  250.         mov word ptr jmpout+1,si    ;move timer int addr to jmpout
  251.         mov word ptr jmpout+3,cx
  252.         mov dx,offset ITRENT        ;give dos the intr entry to this code
  253.         mov ax,251CH            ;request dos to set up a vector
  254.         int 21H                ;do it
  255.     mov dx,offset INIT        ;move the ending addr of the resident
  256.                     ;portion of the code
  257.     int     27H                     ;terminate and stay resident
  258. BEGIN endp
  259. ;
  260. beep proc near            ;beep the speaker
  261.     mov  bx,1000
  262.     in   al,61h
  263.     push ax
  264. more:    and  al,0fch
  265.     out  61h,al
  266.     mov  cx,50
  267. ab:     LOOP    ab
  268.     or al,2
  269.     out  61h,al
  270.     mov  cx,50
  271. bc:    loop bc
  272.     dec  bx
  273.     jnz  more
  274.     pop  ax
  275.     out  61h,al
  276.     ret
  277. beep    endp
  278.  
  279. cseg ends
  280. end BEGIN
  281.